package it.sd.wdc.spider.htmlbrowser;

import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;

public class PageValues {

	private Hashtable<String, LinkedList<String>> tabella = new Hashtable<String, LinkedList<String>>();
	
	public void addValore(String name, String value) {
		LinkedList<String> valori = tabella.get(name);
		if (valori == null) {
			valori = new LinkedList<String>();
			tabella.put(name, valori);
		}
		valori.add(value);
	}

	public void putValues(String name, LinkedList<String> valori) {
		tabella.put(name, valori);
	}

	public String getSingleValue(String name){
		LinkedList<String> valori = tabella.get(name);
		if ((valori!=null)&&(valori.size()>0)) {
			return valori.element();
		} else {
			return null;
		}
	}
	
	public LinkedList<String> getListValues(String name){
		return tabella.get(name);
	}
	
	public Iterator<String> iterateKeys() {
		return tabella.keySet().iterator();
	}
	
	public String toString() {
		StringBuffer b = new StringBuffer();
		
		for (Iterator<String> iter = tabella.keySet().iterator(); iter.hasNext();) {
			String element = iter.next();
			b.append(element).append("=").append(tabella.get(element)).append("\n");
		}
		
		return b.toString();
	}
}
